<template>
    <div class="scfs">
        <div class="my-header">
            <div style="position:relative; top:10px; height:30px;width:100%">
                <div style="position: absolute; right: 10px;">
                    <a-space>
                        <el-button type="success" :icon="CirclePlus" class="stbutenxz"
                            @click="planOrderDetailsAdd">新增行</el-button>
                        <a-button type="outline" @click="save">保存</a-button>
                        <!-- <a-button type="outline">查询</a-button>
                        <a-button type="outline" @click="planOrderDetailsAdd">新增</a-button> -->
                        <a-button v-if="pageData.letmap1 == 0" type="outline" @click="toExamine('1')">审核</a-button>
                        <a-button v-if="planOrderDetails.letmap == 0" type="outline" @click="toExamine('0')">反审</a-button>
                        <a-button v-if="planOrderDetails.letmap == 0" type="outline">成品面料信息维护</a-button>
                        <a-button v-if="planOrderDetails.letmap == 0" type="outline" @click="exCustomer">导入台巨客户</a-button>
                    </a-space>
                </div>
                <div>
                    <a-form :model="form.a">
                        <a-row>
                            <a-col :span="5">
                                <a-form-item field="clientDyeCode" label="制单" label-col-flex="50px">
                                    <a-input :disabled="planOrderDetails.letmap == 2" v-model="form.a.clientDyeCode"
                                        style="width:270px" />
                                </a-form-item>
                            </a-col>
                            <a-col :span="5">
                                <a-form-item field="clientDyeCode" label="审核" label-col-flex="50px">
                                    <a-input v-model="form.a.clientDyeCode" style="width:270px" />
                                </a-form-item>
                            </a-col>
                            <a-col :span="5">
                                <!-- <el-button type="primary" :icon="Search" class="stbutencx"
                                    style="margin-left: 5px;">查询</el-button>  -->

                            </a-col>

                        </a-row>
                    </a-form>
                    <!-- <el-button type="success" :icon="CirclePlus" class="stbutenxz"
            @click="planOrderDetailsAdd">新增</el-button> -->
                </div>
            </div>
            <div style="height: 24px;width: 100%;border-bottom: 1px solid #e5e7eb; margin-bottom: 15px;"></div>
            <div class="search-form" v-if="headerShow">
                <el-row>
                    <el-col :span="13">
                        <div class="grid-content ep-bg-purple">
                            <a-form ref="formRef" :model="form.a">
                                <a-row>
                                    <a-col :span="8">
                                        <a-form-item field="authorizedStrengthTime" label="下单日期" label-col-flex="110px">
                                            <a-date-picker  popup-container="html"  class="bacClass" v-model="form.a.authorizedStrengthTime"
                                                style="width: 270px;" />
                                        </a-form-item>
                                    </a-col>
                                    <a-col :span="8">
                                        <a-form-item field="orderCode" label="订单号" label-col-flex="110px">
                                            <!-- <a-select popup-container="html"  :style="{ width: '320px' }" v-model="form.a.authorizedStrengthTime" allow-clear>
                            </a-select> -->
                                            <!-- <a-date-picker  popup-container="html"  v-model="form.a.authorizedStrengthTime" style="width: 270px;" /> -->
                                            <a-input class="bacClass" v-model="form.a.orderCode" readonly
                                                style="width:270px" />
                                        </a-form-item>
                                    </a-col>
                                    <a-col :span="8">
                                        <a-form-item field="placeDepartment" label="下单部门" label-col-flex="110px">
                                            <!-- <a-select popup-container="html"  :style="{ width: '270px' }" v-model="form.a.placeDepartment" @focus="placeDepartmentFun">
                                                <a-option v-for="item of basicData.ProductionMode" :value="item.id"
                                                    :key="item.id" :label="item.productionMode" />
                                            </a-select> -->
                                            <a-select popup-container="html"  class="bacClass" :loading="loading" :allowClear="true"
                                                @search="placeDepartmentSear" v-model="form.a.placeDepartment"
                                                :filter-option="false" allow-search style="width:270px;"
                                                :trigger-props="{ autoFitPopupMinWidth: true }" @focus="placeDepartmentFun">
                                                <a-option v-for="item in pageDataList" :label="item.name"
                                                    :value="item.name">{{
                                                        item.name }}</a-option>
                                            </a-select>

                                        </a-form-item>
                                    </a-col>

                                    <a-col :span="8">
                                        <a-form-item field="lastDeliveryTime" label="交货日期" label-col-flex="110px">
                                            <a-date-picker  popup-container="html"  class="bacClass" v-model="form.a.lastDeliveryTime"
                                                style="width: 270px;" />
                                        </a-form-item>
                                    </a-col>

                                    <a-col :span="8">
                                        <a-form-item field="clientDyeCode" label="客染整单号" label-col-flex="110px">
                                            <a-input class="bacClass" v-model="form.a.clientDyeCode" style="width:270px" />
                                        </a-form-item>
                                    </a-col>


                                    <a-col :span="8">
                                        <a-form-item field="testCriterion" label="测试标准" label-col-flex="110px">
                                            <a-select popup-container="html"  class="bacClass" :style="{ width: '270px' }"
                                                v-model="form.a.testCriterion" allow-clear @focus="testCriterionFun">
                                                <a-option v-for="item of basicData.VerifyStandard" :value="item.id"
                                                    :key="item.id" :label="item.verifyStandard"
                                                    @click="testCriterionCk(item.verifyStandard)" />
                                            </a-select>
                                        </a-form-item>
                                    </a-col>


                                    <a-col :span="8">
                                        <a-form-item field="dyeAuditDate" label="总部审核时间" label-col-flex="110px">
                                            <a-date-picker  popup-container="html"  class="bacClass" v-model="form.a.dyeAuditDate"
                                                style="width: 270px;" />
                                        </a-form-item>
                                    </a-col>

                                    <a-col :span="8">
                                        <a-form-item field="customOrderCode" label="客户订单号" label-col-flex="110px">
                                            <a-input class="bacClass" v-model="form.a.customOrderCode"
                                                style="width:270px" />
                                        </a-form-item>
                                    </a-col>

                                    <a-col :span="8">
                                        <a-form-item field="coloringIlluminant" label="对色光源" label-col-flex="110px">
                                            <a-select popup-container="html"  class="bacClass" :loading="loading" :allowClear="true"
                                                @search="coloringIlluminantSear" v-model="form.a.coloringIlluminant"
                                                :filter-option="false" allow-search style="width:270px;"
                                                :trigger-props="{ autoFitPopupMinWidth: true }" @change="selectChange"
                                                @focus="coloringIlluminantFun">
                                                <a-option v-for="item in pageDataList" :label="item.colourLight"
                                                    :value="item.colourLight">{{ item.colourLight }}</a-option>
                                            </a-select>
                                        </a-form-item>
                                    </a-col>



                                    <a-col :span="8">
                                        <a-form-item field="customName" label="客户名称" label-col-flex="110px"
                                            :validate-trigger="['change', 'blur']"
                                            :rules="[{ required: true, message: '客户名称必填' }]">

                                            <!-- <a-select popup-container="html"  v-if="showJu" :style="{ width: '270px' }" v-model="form.a.customName">
                                    <a-option v-for="item of basicData.custom" :value="item.id" :key="item.id"
                                        :label="item.customName" />
                                </a-select>

                                <a-select popup-container="html"  v-else="showJu" :style="{ width: '270px' }" v-model="form.a.customName" disabled>
                                    <a-option v-for="item of basicData.custom" :value="item.id" :key="item.id"
                                        :label="item.customName" />
                                </a-select> -->

                                            <a-select popup-container="html"  class="bacClass" :loading="loading" :allowClear="true"
                                                @search="customNameSear" v-model="form.a.customName" :filter-option="false"
                                                allow-search style="width:270px;"
                                                :trigger-props="{ autoFitPopupMinWidth: true }" @focus="customNameFun"
                                                @chenge="orderCodeFun">
                                                <a-option v-for="item in pageDataList" :label="item.customName"
                                                    :value="item.customName" @click="deliveryAddressAll(item.id)">{{
                                                        item.customName }}</a-option>
                                            </a-select>

                                        </a-form-item>
                                    </a-col>

                                    <a-col :span="8">
                                        <a-form-item field="orderNature" label="订单性质" label-col-flex="110px">
                                            <a-select popup-container="html"  class="bacClass" :style="{ width: '270px' }"
                                                v-model="form.a.orderNature" allow-clear @focus="orderNatureFun('订单性质')">
                                                <a-option v-for="item of basicData.orderNature" :value="item.id"
                                                    :key="item.id" :label="item.detailName" />
                                            </a-select>
                                        </a-form-item>
                                    </a-col>

                                    <a-col :span="8">
                                        <a-form-item field="labelFormatCode" label="标签格式" label-col-flex="110px">
                                            <!-- <a-select popup-container="html"  :style="{ width: '270px' }" v-model="form.a.labelFormatCode" allow-clear>
                                    <a-option v-for="item of basicData.labelFormat" :value="item.id" :key="item.id"
                                        :label="item.labelFormat" />
                                </a-select> -->

                                            <a-select popup-container="html"  class="bacClass" :loading="loading" :allowClear="true"
                                                @search="labelFormatCodeSear" v-model="form.a.labelFormatCode"
                                                :filter-option="false" allow-search style="width:270px;"
                                                :trigger-props="{ autoFitPopupMinWidth: true }" @change="selectChange"
                                                @focus="labelFormatCodeFun">
                                                <a-option v-for="item in pageDataList" :label="item.labelFormat"
                                                    :value="item.labelFormat">{{ item.labelFormat }}</a-option>
                                            </a-select>
                                        </a-form-item>
                                    </a-col>

                                    <a-col :span="8">
                                        <a-form-item field="customOrderName" label="客订名称" label-col-flex="110px">
                                            <a-input class="bacClass" v-if="showJu" v-model="form.a.customOrderName"
                                                style="width:270px" />
                                            <a-input class="bacClass" v-else="showJu" v-model="form.a.customOrderName"
                                                readonly style="width:270px" />
                                        </a-form-item>
                                    </a-col>

                                    <a-col :span="8">
                                        <a-form-item field="repairCause" label="回修原因" label-col-flex="110px">
                                            <!-- <a-input v-model="form.a.repairCause" style="width:270px" /> -->
                                            <a-select popup-container="html"  class="bacClass" :loading="loading" :allowClear="true"
                                                @search="repairCauseSear" v-model="form.a.repairCause"
                                                :filter-option="false" allow-search style="width:270px;"
                                                :trigger-props="{ autoFitPopupMinWidth: true }" @change="selectChange"
                                                @focus="repairCauseFun">
                                                <a-option v-for="item in pageDataList" :label="item.repairCause"
                                                    :value="item.repairCause">{{ item.repairCause }}</a-option>
                                            </a-select>
                                        </a-form-item>
                                    </a-col>

                                    <a-col :span="8">
                                        <a-form-item field="deliveryAddress" label="送货地址" label-col-flex="110px">
                                            <a-input class="bacClass" v-model="form.a.deliveryAddress"
                                                style="width:270px" />
                                        </a-form-item>
                                    </a-col>


                                    <a-col :span="8">
                                        <a-form-item field="ultimatelyBuyer" label="最终买家" label-col-flex="110px">

                                            <a-select popup-container="html"  class="bacClass" :loading="loading" :allowClear="true"
                                                @search="customNameSear" v-model="form.a.ultimatelyBuyer"
                                                :filter-option="false" allow-search style="width:270px;"
                                                :trigger-props="{ autoFitPopupMinWidth: true }" @focus="customNameFun"
                                                @chenge="orderCodeFun">
                                                <a-option v-for="item in pageDataList" :label="item.customName"
                                                    :value="item.customName">{{
                                                        item.customName }}</a-option>
                                            </a-select>

                                        </a-form-item>
                                    </a-col>

                                    <a-col :span="8">
                                        <a-form-item field="marketType" label="面料销售类型" label-col-flex="110px">
                                            <!-- <a-select popup-container="html"  :style="{ width: '270px' }" v-model="form.a.marketType" allow-clear
                                                @focus="orderNatureFun('面料销售类型')">
                                                <a-option v-for="item of basicData.plusMaterial" :value="item.id"
                                                    :key="item.id" :label="item.plusMaterial" />
                                            </a-select> -->
                                            <a-select popup-container="html"  class="bacClass" :style="{ width: '270px' }"
                                                v-model="form.a.marketType" style="width:270px">
                                                <a-option value="ok">米</a-option>
                                                <a-option value="Y1">码</a-option>
                                                <a-option value="Y2">公斤</a-option>
                                                <a-option value="Y3">磅数</a-option>
                                            </a-select>
                                        </a-form-item>
                                    </a-col>

                                    <a-col :span="8">
                                        <a-form-item field="exchangeCalorieClassify" label="流转卡类型" label-col-flex="110px">
                                            <!-- <a-select popup-container="html"  :style="{ width: '270px' }" v-model="form.a.labelFormatCode" allow-clear>
                                    <a-option v-for="item of basicData.labelFormat" :value="item.id" :key="item.id"
                                        :label="item.labelFormat" />
                                </a-select> -->

                                            <a-select popup-container="html"  class="bacClass" :loading="loading" :allowClear="true"
                                                @search="exchangeCalorieClassifySear"
                                                v-model="form.a.exchangeCalorieClassify" :filter-option="false" allow-search
                                                style="width:270px;" :trigger-props="{ autoFitPopupMinWidth: true }"
                                                @change="selectChange" @focus="exchangeCalorieClassifyFun">
                                                <a-option v-for="item in pageDataList" :label="item.exchangeCalorieClassify"
                                                    :value="item.exchangeCalorieClassify">{{
                                                        item.exchangeCalorieClassify }}</a-option>
                                            </a-select>
                                        </a-form-item>
                                    </a-col>

                                    <a-col :span="24">
                                        <a-form-item field="remark" label="布号备注" label-col-flex="110px">
                                            <!-- <a-input v-model="form.a.customOrderName" style="width:270px" /> -->
                                            <el-input class="bacClass" v-model="form.a.remark" :rows="1" type="textarea"
                                                style="width:810px" />
                                        </a-form-item>
                                    </a-col>


                                    <a-col :span="8">
                                        <a-form-item field="hqCraft" label="总部工艺" label-col-flex="110px">
                                            <!-- <a-select popup-container="html"  :style="{ width: '310px' }" v-model="form.a.hqCraft" allow-clear>
                                                <a-option v-for="item of basicData.plusMaterial" :value="item.id"
                                                    :key="item.id" :label="item.plusMaterial" />
                                            </a-select> -->
                                            <el-input class="bacClass" v-model="form.a.hqCraft" />
                                        </a-form-item>
                                    </a-col>

                                    <a-col :span="16">
                                        <a-form-item field="pack" label="包装要求" label-col-flex="110px">
                                            <a-input class="bacClass" v-model="basicData.pack" style="width:150px" />
                                            <a-input class="bacClass" v-model="basicData.packA"
                                                style="width:160px; margin-left: 10px;" />
                                            <a-input class="bacClass" v-model="basicData.packB"
                                                style="width:160px; margin-left: 10px;" />
                                        </a-form-item>
                                    </a-col>




                                </a-row>
                            </a-form>
                        </div>
                    </el-col>
                    <el-col :span="6">
                        <div class="grid-content ep-bg-purple-light">
                            <div style="width: 100%; height: 300px; padding-right: 5px; padding-left:5px">
                                <a-form :model="form.a">
                                    <a-row>
                                        <a-col :span="23">
                                            <a-form-item field="clientDyeCode" label="客户要求" label-col-flex="80px">
                                            </a-form-item>
                                        </a-col>
                                    </a-row>
                                    <!-- <AgGridVuesCopys style="height:345px;" class="ag-theme-alpine" :columnDefs="askList"
                                        :rowData="form.a.requirement" :defaultColDef="defaultColDefTc"
                                        rowSelection="multiple">
                                    </AgGridVuesCopys> -->
                                    <a-textarea v-model="form.a.require" default-value="" :auto-size="{
                                        minRows: 15,
                                        maxRows: 15
                                    }"
                                        style="margin-top: 0px;height: 250px;background-color: #fff;border: 1px solid #ccc;" />
                                </a-form>
                            </div>
                        </div>
                    </el-col>
                    <el-col :span="5">
                        <div class="grid-content ep-bg-purple">
                            <div style="height: 300px; width: 100%;">
                                <a-form :model="shrink">
                                    <a-row>
                                        <a-col :span="23">
                                            <a-form-item field="clientDyeCode" label="缩水要求" label-col-flex="80px">
                                                <a-input v-model="shrink.w" style="width:270px">
                                                    <template #prepend>
                                                        W
                                                    </template>
                                                </a-input>
                                                <a-input v-model="shrink.l" style="width:270px; margin-left:10px;">
                                                    <template #prepend>
                                                        L
                                                    </template>
                                                </a-input>
                                            </a-form-item>
                                        </a-col>
                                    </a-row>
                                    <AgGridVuesCopys style="height:250px;" class="ag-theme-alpine" :columnDefs="testAsk"
                                        :rowData="testAskList.list" :defaultColDef="defaultColDef" rowSelection="multiple"
                                        :localeText="localeText1">
                                    </AgGridVuesCopys>
                                </a-form>


                            </div>


                        </div>
                    </el-col>
                </el-row>
            </div>

            <div class="my-divisders">
                <a-divider orientation="center">
                    <icon-double-up v-if="headerShow" @click="headerShow = false" :strokeWidth="2" :size="18" />
                    <icon-double-down v-else @click="headerShow = true" :strokeWidth="2" :size="18" />
                </a-divider>
            </div>
        </div>

        <!-- <div style="padding:10px"></div> -->
        <div ref="tablediv" style="padding: 10px; box-sizing: border-box;min-height:100%;background-color: #fff;">
            <a-tabs   :lazy-load="true" default-active-key="2" @change="guanxi">
                <a-tab-pane key="2" title="订单明细列表">
                    <div style="height:5px;"></div>

                    <AgGridVuesCopys style="height:340px" class="ag-theme-alpine" :columnDefs="tco"
                        :rowData="form.a.planOrderDetails" :defaultColDef="defaultColDefTc" :enableColResize="true"
                        rowSelection="multiple" @grid-ready="gridReadyeB" :localeText="localeText1">
                    </AgGridVuesCopys>
                </a-tab-pane>
                <a-tab-pane key="1" title='总部坯布信息'>
                    <div class="my-tool-bar">
                        <a-button type="primary" @click="countBu">查询</a-button>
                    </div>
                    <div style="height:15px;"></div>
                    <!-- <a-table :columns="total" :data="form.a.planOderGreys" /> -->
                    <AgGridVuesCopys style="height:300px;" class="ag-theme-alpine" :columnDefs="total" :rowData="planOderGreys"
                        :defaultColDef="defaultColDefTc" rowSelection="multiple" :localeText="localeText1">
                    </AgGridVuesCopys>
                </a-tab-pane>
            </a-tabs>
        </div>
        <a-drawer :drawer-style="{ 'zIndex': 9999 }" placement="bottom" :mask-closable="false" width="100" height="100%"
            :visible="pageData.importAdd" unmountOnClose @ok="sideaOk" @cancel="sideaNo" cancel-text='关闭'
            :ok-text="mobanYnKey == 1 ? '保存' : '退至可用数据'">

            <template #title>
                <div style="position: absolute; right: 50px;">
                    <!-- <Toolbar :items="['查询 ', '确定', 'Excel资料导入', '导出']" @add="addHandler" @import="importHandler"
                        @del="deleteHandler" @select="selectHandler" @export="exports" @excel="downloadHandler">
                    </Toolbar> -->
                    <el-button plain :icon="Search" @click="guanxiCount">查询</el-button>
                    <!-- <el-button plain @click="yesOrder">确定</el-button> -->
                    <el-button plain :icon="CirclePlus" @click="downloadHandler">模板下载</el-button>
                    <el-button plain :icon="CirclePlus" @click="importHandler">导入</el-button>
                </div>

                <div class="my-tool-bar">
                    后台巨客户
                    <!-- <el-button type="primary" :icon="CirclePlus" class="stbutencx"
                        @click="importHandler">导入后台巨客户</el-button> -->
                    <!-- <el-button type="primary" :icon="CirclePlus" class="stbutencx"
                        @click="importHandler">导入后台巨客户按钮</el-button> -->
                    <!-- <el-button type="primary" :icon="CirclePlus" class="stbutencx" @click="downloadHandler">模板下载</el-button>
                    <el-button type="primary" :icon="CirclePlus" class="stbutencx" @click="yesOrder">确定</el-button> -->
                </div>
            </template>
            <div>
                <a-form :model="guanxiForm">
                    <a-row :gutter="16">
                        <a-col :span="4">
                            <a-form-item label="客户订单号:" label-col-flex="100px">
                                <a-input class="bacClass" v-model="guanxiForm.customOrderCode" />
                            </a-form-item>
                        </a-col>
                        <a-col :span="4">
                            <a-form-item field="clothCode" label="布号:" label-col-flex="100px">
                                <!-- <el-select v-model="guanxiForm.clothCode" filterable @click="selectChange">
                                    <el-option v-for="item in optionsList" :key="item.id" :label="item.clothCode"
                                        :value="item.clothCode" />
                                </el-select> -->
                                <a-select popup-container="html"  class="bacClass" :loading="loading" :allowClear="true" @search="clothCodeSearch"
                                    v-model="guanxiForm.clothCode" :filter-option="false" allow-search
                                    @focus="clothCodeBoSel" style="width:270px;"
                                    :trigger-props="{ autoFitPopupMinWidth: true }" @change="clothChanges">
                                    <a-option v-for="item in optionsList" :label="item.clothCode" :value="item.clothCode">{{
                                        item.clothCode + '——' + item.brandName
                                    }}</a-option>
                                </a-select>


                            </a-form-item>
                        </a-col>
                        <a-col :span="4">
                            <a-form-item field="productName" label="品名" label-col-flex="100px">
                                <!-- <el-select v-model="guanxiForm.productName" filterable @click="selectPin">
                                    <el-option v-for="item in pinList" :key="item.id" :label="item.brandName"
                                        :value="item.brandName" />
                                </el-select> -->
                                <a-select popup-container="html"  class="bacClass" :loading="loading" :allowClear="true" @search="clothCodeSearchA"
                                    v-model="guanxiForm.productName" :filter-option="false" allow-search
                                    @focus="clothCodeBoSelA" style="width:270px;"
                                    :trigger-props="{ autoFitPopupMinWidth: true }" @change="clothChangess">
                                    <a-option v-for="item in pinList" :label="item.brandName" :value="item.brandName">{{
                                        item.brandName + '————' + item.clothCode
                                    }}</a-option>
                                </a-select>

                            </a-form-item>
                        </a-col>
                        <a-col :span="4">
                            <a-form-item field="colorCode" label="色号" label-col-flex="100px">
                                <a-input class="bacClass" v-model="guanxiForm.colorCode" />
                            </a-form-item>
                        </a-col>
                        <a-col :span="4">
                            <a-form-item field="colorName" label="色称" label-col-flex="100px">
                                <a-input class="bacClass" v-model="guanxiForm.colorName" />
                            </a-form-item>
                        </a-col>
                    </a-row>
                </a-form>
            </div>
            <div style="height:15px;"></div>
            <a href="#" style="color:blue">订单明细列表</a>
            <div style="height:10px;"></div>

            <a-tabs   :lazy-load="true" :default-active-key="1" @change="mobanYn">
                <a-tab-pane :key="1" title="可用数据">
                    <AgGridVuesCopys :rowHeight="33" :headerHeight="33" style="height:72vh;" class="ag-theme-alpine" :columnDefs="hugeCustomer"
                        :rowData="orderCustomList.list" :defaultColDef="defaultColDefBc" rowSelection="multiple"
                        @grid-ready="gridReadyB" :suppressCopyRowsToClipboard="true" :localeText="localeText1">
                    </AgGridVuesCopys>
                </a-tab-pane>
                <a-tab-pane :key="2" title="已用数据">
                    <AgGridVuesCopys :rowHeight="33" :headerHeight="33" style="height:72vh;" class="ag-theme-alpine" :columnDefs="hugeCustomer"
                        :rowData="orderCustomList.list" :defaultColDef="defaultColDefBc" rowSelection="multiple"
                        @grid-ready="gridReadyC" :localeText="localeText1">
                    </AgGridVuesCopys>
                </a-tab-pane>
            </a-tabs>
        </a-drawer>
    </div>
</template>

<script lang="ts">
import { post, get } from "@/api/http";
import { Search, CirclePlus, Delete, EditPen } from "@element-plus/icons-vue";
import { ref, reactive, onMounted, onActivated, onUnmounted, watch, provide } from "vue";
import axios from "axios";
import Toolbar from "@/components/Toolbar.vue";

import filedownload from 'js-file-download';
import tagRender from '@/components/SelectRenderer.vue'
import cheCk from '@/views/Aps/planOrderA/cheCkBoxComm/cheCk.vue'                               //快反需求
import cheCkBumpWhite from '@/views/Aps/planOrderA/cheCkBoxComm/cheCkBumpWhite.vue'             //撞白
import CheCkdialPrinting from '@/views/Aps/planOrderA/cheCkBoxComm/CheCkdialPrinting.vue'       //拔印
import checheCkEdgeCK from '@/views/Aps/planOrderA/cheCkBoxComm/cheCkEdge.vue'                  //珠地边
import cheCkFirstRate from '@/views/Aps/planOrderA/cheCkBoxComm/cheCkFirstRate.vue'             //一等品
import cheCKneedEnterPot from '@/views/Aps/planOrderA/cheCkBoxComm/cheCKneedEnterPot.vue'       //需进缸
import cheCkrcInfo from '@/views/Aps/planOrderA/cheCkBoxComm/cheCkrcInfo.vue'                   // 白色RC处理
import cheCkrepeatPack from '@/views/Aps/planOrderA/cheCkBoxComm/cheCkrepeatPack.vue'           //重打包
import cheCkstainResistance from '@/views/Aps/planOrderA/cheCkBoxComm/cheCkstainResistance.vue'//白色防沾处理
import cheCktakeDyeFee from '@/views/Aps/planOrderA/cheCkBoxComm/cheCktakeDyeFee.vue'           //收取染费
import cheCkwetRubbing from '@/views/Aps/planOrderA/cheCkBoxComm/cheCkwetRubbing.vue'           //问擦提升
import cheCkChlorineResistant from '@/views/Aps/planOrderA/cheCkBoxComm/cheCkChlorineResistant.vue'
import cheCkResistanceYellow from '@/views/Aps/planOrderA/cheCkBoxComm/cheCkResistanceYellow.vue'
import cheCKStaining from '@/views/Aps/planOrderA/cheCkBoxComm/cheCKStaining.vue'

import selectGreyCode from '@/views/Aps/planOrderA/selectList/selectGreyCode.vue'           //问擦提升
import selectGreyName from '@/views/Aps/planOrderA/selectList/selectGreyName.vue'           //问擦提升
import selectColorCode from '@/views/Aps/planOrderA/selectList/selectColorCode.vue'         //色号
import selectColorCodeZ from '@/views/Aps/planOrderA/selectList/selectColorCodeZ.vue'         //色号
import selectColorName from '@/views/Aps/planOrderA/selectList/selectColorName.vue'         //色称
import selectColorNameZ from '@/views/Aps/planOrderA/selectList/selectColorNameZ.vue'
import selectCylinder from '@/views/Aps/planOrderA/selectList/selectCylinder.vue'
import { localeText } from '@/api/aggridZw'
import selectAffirmColor from '@/views/Aps/planOrderA/selectList/selectAffirmColor.vue'
import selectGreyType from '@/views/Aps/planOrderA/selectList/selectGreyType.vue'
import selectTrimCharges from '@/views/Aps/planOrderA/selectList/selectTrimCharges.vue'
import selectDyeingType from '@/views/Aps/planOrderA/selectList/selectDyeingType.vue'
import selectColorDepth from '@/views/Aps/planOrderA/selectList/selectColorDepth.vue'
import selectWorkshop from '@/views/Aps/planOrderA/selectList/selectWorkshop.vue'
import selectOrdering from '@/views/Aps/planOrderA/selectList/selectOrdering.vue'
import selectFabricNumberZ from '@/views/Aps/planOrderA/selectList/selectFabricNumberZ.vue'

import selectProductionMode from '@/views/Aps/planOrderA/selectList/selectProductionMode.vue'
import selectMachinType from '@/views/Aps/planOrderA/selectList/selectMachinType.vue'
import selectSeason from '@/views/Aps/planOrderA/selectList/selectSeason.vue'
import selectTradeCode from '@/views/Aps/planOrderA/selectList/selectTradeCode.vue'
import { Form, Message, Modal, Pagination } from "@arco-design/web-vue"
import emitter from "@/hooks/useEventBus";

interface ClothSet {
    id?: any;
    serialNumber?: number | undefined,
    mercery?: string | undefined;
    deleteState?: any
    remark?: string | undefined;
    productionMode?: string | undefined;
    createName?: string | undefined;
    createTime?: string | undefined;
    updateName?: string | undefined;
    updateTime?: string | undefined;
}
interface pagings {
    size: number | string,
    total: number | string,
}
export default {
    name: "productionMode",
    setup() {
        emitter.on('inOne', (res: any) => {
            pageData.letmap1 = res
            form.a.clientDyeCode = res
            console.log(pageData.letmap1, '看看是修改还是详情')
        })
        const headerShow = ref<boolean>(true)
        const basicData = reactive({
            serialNo: 0,
            pack: '',
            packA: '',
            packB: '',
            dictTypeList: ['订单性质', '结算方式', '面料销售类型', '结算公司'],
            ProductionMode: [],
            machinType: [],
            ExchangecalorieClassify: [],
            saleType: [],
            labelFormat: [],
            UrgentCategory: [],

            orderNature: [],
            Calculation: [],
            plusMaterial: [],
            corporation: [],
            custom: [],
            hrEmployee: [],
            baCompany: [],
            VerifyStandard: [],
            coloringMatch: [],
            seasonSet: []

        });
        const pageData = reactive<{
            clothList: ClothSet[]
            showAdd: boolean
            sideTitle: string
            dropDownData: any
            pageLoading: boolean,
            theight: number,
            tablediv: any,
            rHeight: number | undefined,
            importAdd: boolean,
            letmap1: any
        }>({
            clothList: [],
            showAdd: false,
            sideTitle: "计划订单",
            dropDownData: "",
            pageLoading: false,
            theight: 0,
            tablediv: null,
            rHeight: 0,
            importAdd: false,
            letmap1: 0
        });
        const form: any = reactive(
            {
                a: {
                    exchangeCalorieClassify: '',   //流转卡类型
                    authorizedStrengthTime: '',   //下单日期
                    orderCode: '',                //订单号
                    placeDepartment: '',          //下单部门
                    testCriterion: '',            //测试标准

                    lastDeliveryTime: '',        //交货日期
                    clientDyeCode: '',           //客户染整单号
                    coloringIlluminant: '',      //对色光源
                    customOrderCode: '',         //客户订单号

                    dyeAuditDate: '',            //总部审核时间
                    customName: '',              //客户名称
                    orderNature: '',             //订单性质
                    labelFormatCode: '',         //标签格式

                    customOrderName: '',         //客订名称
                    repairCause: '',             //回修原因
                    deliveryAddress: '',         //送货地址
                    ultimatelyBuyer: '',         //最终买家

                    marketType: '',              //面料销售类型
                    hqCraft: '',                 //总部工艺
                    pack: '',                    //包装要求
                    remark: '',                  //布号备注
                    require: '',

                    planOrderDetails: [],         //详情
                    planOrderTest: [],             //测试标准
                    requirement: []                 //要求
                }
            }
        );
        let guanxiForm = reactive({
            customOrderCode: '',
            clothCode: '',
            productName: '',
            colorCode: '',
            colorName: '',
            auditState: 0
        });

        let shrink = reactive({
            l: '',
            w: ''
        })

        const testAsk = [
            { headerName: "测试项目", field: "fabricTestItem", },
            { headerName: "测试要求", field: "verifyStandard" },
            { headerName: "客户要求", field: "verifyMaxNum" },
        ];

        const askList = [
            { headerName: "要求项目", field: "requiredItems", },
            { headerName: "本次要求", field: "nowRequirement" },
            { headerName: "默认要求", field: "defaultRequirement" },
            { headerName: "布种", field: "unit" },
            { headerName: "单位", field: "greyType" },
            { headerName: "备注", field: "remark" }
        ];
        const defaultColDef = {
            sortable: true,
            filter: true,
            flex: 1,
            resizable: true,
        };

        const defaultColDefBc = {
            sortable: true,
            filter: true,
            resizable: true,
        };
        const testAskList = reactive({
            list: []
        });
        const planOderGreys = ref([])
        /********************************************************************************订单明细***************************************************************************** */

        function xuHaoFun(params) {
            let i = params.node.rowIndex
            i = i + 1
            return i ? i : null
        }

        const columnsOrder = [
            // {
            //     rowHeight: 100,
            //     headerName: '',//选择列头部显示的文字，可以为空
            //     checkboxSelection: true,//设置为ture显示为复选框
            //     headerCheckboxSelection: true, //表头是否也显示复选框，全选反选用
            //     pinned: 'left', //固定再左边
            //     width: 50 //列的宽度
            // },
            {
                headerName: "序号",
                cellRenderer: xuHaoFun,
                width: 100
            },
            {
                headerName: "生产方式",
                field: "productionMode",
                width: 200
            },
            {
                headerName: "加工类型",
                field: "machinType",
                width: 200
            },
            {
                headerName: "染色类型",
                field: "dyeingType",
                width: 200
            },
            {
                headerName: "缸型",
                field: "cylinderType",
                width: 200
            },
            {
                headerName: "车间",
                field: "workshop",
                cellEditor: "agSelectCellEditor",
                editable: true,
                cellEditorParams: { values: ['染部A', '染部B'] },
                width: 200
            },
            { headerName: "布号", field: "clothCode", width: 200 },
            { headerName: "品名", field: "productName", width: 200 },
            { headerName: "色号", field: "colorCode", width: 200 },
            { headerName: "色称", field: "colorName", width: 200 },
            { headerName: "确认色", field: "affirmColor", width: 200 },
            {
                headerName: "颜色深浅",
                field: "colorDepth",
                width: 200
            },
            {
                headerName: "对色资料",
                field: "contrastColor",
                cellEditor: "agSelectCellEditor",
                editable: true,
                cellEditorParams: { values: [1, 2] },
                width: 200
            },
            { headerName: "匹数", field: "houseNum", editable: true, width: 200 },
            { headerName: "成品重量", field: "finishedWeight", editable: true, width: 200 },
            { headerName: "投染重量", field: "castDyeWeight", editable: true, width: 200 },
            { headerName: "总损耗", field: "allLoss", editable: true, width: 200 },


            {
                headerName: "整理收费项目",
                field: "trimCharges",
                width: 200
            },
            { headerName: "合染类型", field: "joinDyeType", width: 200 },
            { headerName: "一等品", field: "firstRate", width: 200 },
            { headerName: "撞白", field: "bumpWhite", width: 200 },
            { headerName: "温擦提升", field: "wetRubbing", width: 200 },
            { headerName: "耐氨提升", field: "chlorineResistant", editable: true, width: 200 },
            { headerName: "白色防粘处理", field: "stainResistance", width: 200 },
            { headerName: "抗黄处理", field: "resistanceYellow", editable: true, width: 200 },
            { headerName: "拔印", field: "dialPrinting", width: 200 },
            { headerName: "重打包", field: "repeatPack", width: 200 },
            { headerName: "需进缸", field: "needEnterPot", width: 200 },
            { headerName: "收取染费", field: "takeDyeFee", width: 200 },
            { headerName: "季节", field: "season", editable: true, width: 200 },
            {
                headerName: "布种类别",
                field: "greyType",
                width: 200
            },
            {
                headerName: "坯布编号", field: "greyCode", width: 200
            },
            { headerName: "坯布名称", field: "greyName", width: 200 },
            { headerName: "成分", field: "ingredient", width: 200 },
            { headerName: "纱支", field: "yarnCount", width: 200 },
            { headerName: "珠地边", field: "edge", width: 200 },
            { headerName: "有效门幅（CM）", field: "efficacious", width: 200 },
            { headerName: "克重（M2）", field: "gramWeight", width: 200 },
            { headerName: "门幅上限", field: "upperLimit", editable: true, width: 200 },
            { headerName: "门幅下限", field: "lowerLimit", editable: true, width: 200 },
            { headerName: "克重上限", field: "gramUpperLimit", editable: true, width: 200 },
            { headerName: "克重下限", field: "gramLowerLimit", editable: true, width: 200 },


            { headerName: "总部商品号", field: "tradeCode", editable: true, width: 200 },
            { headerName: "总部商品名称", field: "tradeName", editable: true, width: 200 },
            { headerName: "总部成品布号", field: "finishedClothCode", editable: true, width: 200 },
            { headerName: "总部成品名称", field: "finishedClothName", editable: true, width: 200 },
            { headerName: "总部商品门幅", field: "tradeEfficacious", editable: true, width: 200 },
            { headerName: "总部商品克重", field: "tradeGramWeight", editable: true, width: 200 },
            { headerName: "总部总部色卡号", field: "hqCardNumber", width: 200 },
            { headerName: "总部原色号", field: "rawColorCode", width: 200 },
            { headerName: "总部原色称", field: "rawColorName", width: 200 },



            { headerName: "客户布号", field: "customClothCode", editable: true, width: 200 },
            { headerName: "客户品名", field: "customProductName", editable: true, width: 200 },
            { headerName: "客户色号", field: "customColorCode", editable: true, width: 200 },
            { headerName: "客户色称", field: "customColorName", editable: true, width: 200 },
            { headerName: "客户po", field: "customPo", editable: true, width: 200 },
            { headerName: "款号", field: "styleNumber", editable: true, width: 200 },
            { headerName: "定型剪办要求", field: "finalize", editable: true, width: 200 },
            { headerName: "质检剪办要求", field: "quality", editable: true, width: 200 },
            // { headerName: "下单部门", field: "orderDepartment", width: 200 },


            { headerName: "回修缸号", field: "repairMachineCode", width: 200 },
            { headerName: "回修布号", field: "repairClothCode", width: 200, },
            { headerName: "回修色号", field: "repairColorCode", width: 200 },
            { headerName: "回修色称", field: "repairColorName", width: 200 },

            { headerName: "台巨prodId", field: "prodId", width: 200 },
            { headerName: "台巨seqNo", field: "seqNo", width: 200 },
            { headerName: "台巨shipto地址", field: "shiptoSite", width: 200 },



            { headerName: "操作", },
        ];
        const defaultColDefTc = {
            sortable: true,
            filter: true,
            flex: 0,
            resizable: true,
        };
        let tco: any[] = columnsOrder.map((o) => {
            //let obj = {}



            if (o.headerName === '操作') {
                o['resizable'] = true
                o['filter'] = false
                o['sortable'] = false
                o["pinned"] = "right"
                o["width"] = 70
                o['cellRenderer'] = {
                    template: `<el-button style="color:red;"  link  @click="s">删除</el-button>`,
                    setup(props: any) {
                        const s = () => {
                            console.log(props.params.data.id, 'look,look');
                            if (props.params.data.id) {
                                post({
                                    url: "aps/orderCustom/delete",
                                    data: [props.params.data.id]
                                }).then(({ data, code }) => {
                                    if (code === 200) {
                                        form.a.planOrderDetails.splice(props.params.rowIndex, 1)
                                        setTimeout(function () { gridOptionyB.value.setRowData(form.a.planOrderDetails); }, 0)
                                    }
                                });
                            } else {
                                form.a.planOrderDetails.splice(props.params.rowIndex, 1)
                                setTimeout(function () { gridOptionyB.value.setRowData(form.a.planOrderDetails); }, 0)
                            }
                            // deleteBzyq(props.params.rowIndex)

                        }
                        return {
                            s
                        }
                    }

                }
            }
            if (o.headerName == '染色类型') {
                o['resizable'] = true
                o['filter'] = false
                o['sortable'] = false
                o["width"] = 200
                o['cellRenderer'] = {
                    template: `<div>
                        <a-select popup-container="html"  class="bacClass" :allowClear="true" v-model="gx" allow-search @change="a" @click="c">
                                    <a-option v-for="item in list" :value="item.jobType">{{item.jobType}}</a-option>
                                </a-select></div>`,
                    setup(props: any) {
                        const gx = ref(props.params.data.dyeingType)
                        const a = (val: any) => {
                            props.params.data.dyeingType = val
                        }
                        const list = ref([])
                        const c = () => {
                            post({
                                url: "/pdm/JobType/getFieldValue",
                                data: {
                                    jobType: ''
                                }
                            }).then(({ data, code }: any) => {
                                if (code === 200) {
                                    list.value = data
                                }
                            })
                        }
                        return {
                            gx,
                            a,
                            c,
                            list
                        }
                    }

                }
            }
            if (o.headerName == '缸型') {
                o['resizable'] = true
                o['filter'] = false
                o['sortable'] = false
                o["width"] = 200
                o['cellRenderer'] = {
                    template: `<div>
                        <a-select popup-container="html"  class="bacClass" :allowClear="true" v-model="gx" allow-search @change="a">
                                    <a-option value="E缸">E缸</a-option>
                                    <a-option value="S缸">S缸</a-option>
                                </a-select></div>`,
                    setup(props: any) {
                        const gx = ref(props.params.data.cylinderType)
                        const a = (val: any) => {
                            props.params.data.cylinderType = val
                        }
                        return {
                            gx,
                            a
                        }
                    }

                }
            }
            if (o.headerName == '颜色深浅') {
                o['resizable'] = true
                o['filter'] = false
                o['sortable'] = false
                o["width"] = 200
                o['cellRenderer'] = {
                    template: `<div>
                        <a-select popup-container="html"  class="bacClass" :allowClear="true" v-model="gx" allow-search @change="a" @click="c">
                                    <a-option v-for="item in list" :value="item.shade">{{item.shade}}</a-option>
                                </a-select></div>`,
                    setup(props: any) {
                        const gx = ref(props.params.data.colorDepth)
                        const a = (val: any) => {
                            props.params.data.colorDepth = val
                        }
                        const list = ref([])
                        const c = () => {
                            post({
                                url: "/pdm/shade/getFieldValue",
                                data: {
                                    shade: ''
                                }
                            }).then(({ data, code }: any) => {
                                if (code === 200) {
                                    list.value = data
                                }
                            })
                        }
                        return {
                            gx,
                            a,
                            c,
                            list
                        }
                    }

                }
            }
            if (o.headerName == '生产方式') {
                o['resizable'] = true
                o['filter'] = false
                o['sortable'] = false
                o["pinned"] = "light"
                o["width"] = 200
                o['cellRenderer'] = selectProductionMode
                o['cellRendererParams'] = {
                    color: (params: any) => {
                        // form.a.planOrderDetails[params.rowIndex].productionMode = params.data.productionMode
                        // setTimeout(function () { gridOptionyB.value.setRowData(form.a.planOrderDetails); }, 0)
                    }
                }
            }
            if (o.headerName == '加工类型') {
                o['resizable'] = true
                o['filter'] = false
                o['sortable'] = false
                o["pinned"] = "light"
                o["width"] = 200
                o['cellRenderer'] = selectMachinType
                o['cellRendererParams'] = {
                    color: (params: any) => {
                        if (form.a.orderCode != '') {
                            if (params.data.serialNo == basicData.serialNo) {
                                machinTypeFun(params.data.machinType)
                            }
                        }

                        if (form.a.orderCode == '') {
                            for (let i = 0; i < form.a.planOrderDetails.length; i++) {
                                if (form.a.planOrderDetails.machinType != '') {
                                    basicData.serialNo = params.data.serialNo
                                    console.log(form.a.planOrderDetails, 'sssssssssssssssssssss', params)
                                    machinTypeFun(params.data.machinType)
                                    break;
                                }
                            }
                        }
                        form.a.planOrderDetails[params.rowIndex].machinType = params.data.machinType

                        setTimeout(function () { gridOptionyB.value.setRowData(form.a.planOrderDetails); }, 0)
                    }
                }
            }

            if (o.headerName == '布号') {
                o['resizable'] = true
                o['filter'] = false
                o['sortable'] = false
                o["pinned"] = "light"
                o["width"] = 200
                o['cellRenderer'] = tagRender
                o['cellRendererParams'] = {
                    color: (params: any, brandName: any) => {
                        form.a.planOrderDetails[params.rowIndex].productName = brandName
                        setTimeout(function () { gridOptionyB.value.setRowData(form.a.planOrderDetails); }, 0)
                    }
                }
            }
            if (o.headerName == '坯布编号') {
                o['resizable'] = true
                o['filter'] = false
                o['sortable'] = false
                o["pinned"] = "light"
                o["width"] = 200
                o['cellRenderer'] = selectGreyCode
                o['cellRendererParams'] = {
                    color: (params: any, grayFabricName: any) => {
                        form.a.planOrderDetails[params.rowIndex].greyName = grayFabricName
                        setTimeout(function () { gridOptionyB.value.setRowData(form.a.planOrderDetails); }, 0)
                    }
                }
            }
            if (o.headerName == '总损耗') {
                o['resizable'] = true
                o['filter'] = false
                o['sortable'] = false
                o["pinned"] = "light"
                o["width"] = 200
                o['cellRenderer'] = {
                    template: `<span>{{s}}%</span>`,
                    setup(props: any) {
                        return {
                            s: props.params.data.allLoss
                        }
                    }

                }
            }
            if (o.headerName == '车间') {
                o['resizable'] = true
                o['filter'] = false
                o['sortable'] = false
                o["pinned"] = "light"
                o["width"] = 200
                o['cellRenderer'] = selectWorkshop
                o['cellRendererParams'] = {
                    color: (params: any, greyCode: any) => {
                        // form.a.planOrderDetails[params.rowIndex].greyCode = greyCode
                        // setTimeout(function () { gridOptionyB.value.setRowData(form.a.planOrderDetails); }, 0)
                    }
                }
            }
            if (o.headerName == '总部商品号') {
                o['resizable'] = true
                o['filter'] = false
                o['sortable'] = false
                o["pinned"] = "light"
                o["width"] = 200
                o['cellRenderer'] = selectTradeCode
                o['cellRendererParams'] = {
                    color: (params: any, greyCode: any) => {
                        form.a.planOrderDetails[params.rowIndex].greyCode = greyCode
                        setTimeout(function () { gridOptionyB.value.setRowData(form.a.planOrderDetails); }, 0)
                    }
                }
            }



            if (o.headerName == '缸号') {
                o['resizable'] = true
                o['filter'] = false
                o['sortable'] = false
                o["pinned"] = "light"
                o["width"] = 200
                o['cellRenderer'] = selectCylinder
                o['cellRendererParams'] = {
                    color: (params: any, greyCode: any) => {
                        // form.a.planOrderDetails[params.rowIndex].greyCode = greyCode
                        // setTimeout(function () { gridOptionyB.value.setRowData(form.a.planOrderDetails); }, 0)
                    }
                }
            }
            if (o.headerName == '总部布号') {
                o['resizable'] = true
                o['filter'] = false
                o['sortable'] = false
                o["pinned"] = "light"
                o["width"] = 200
                o['cellRenderer'] = selectFabricNumberZ
                o['cellRendererParams'] = {
                    color: (params: any, greyCode: any) => {
                        // form.a.planOrderDetails[params.rowIndex].greyCode = greyCode
                        // setTimeout(function () { gridOptionyB.value.setRowData(form.a.planOrderDetails); }, 0)
                    }
                }
            }

            if (o.headerName == '总部色号') {
                o['resizable'] = true
                o['filter'] = false
                o['sortable'] = false
                o["pinned"] = "light"
                o["width"] = 200
                o['cellRenderer'] = selectColorCodeZ
                o['cellRendererParams'] = {
                    color: (params: any, greyCode: any) => {
                        // form.a.planOrderDetails[params.rowIndex].greyCode = greyCode
                        // setTimeout(function () { gridOptionyB.value.setRowData(form.a.planOrderDetails); }, 0)
                    }
                }
            }
            if (o.headerName == '总部色称') {
                o['resizable'] = true
                o['filter'] = false
                o['sortable'] = false
                o["pinned"] = "light"
                o["width"] = 200
                o['cellRenderer'] = selectColorNameZ
                o['cellRendererParams'] = {
                    color: (params: any, greyCode: any) => {
                        // form.a.planOrderDetails[params.rowIndex].greyCode = greyCode
                        // setTimeout(function () { gridOptionyB.value.setRowData(form.a.planOrderDetails); }, 0)
                    }
                }
            }



            if (o.headerName == '商品号') {
                o['resizable'] = true
                o['filter'] = false
                o['sortable'] = false
                o["pinned"] = "light"
                o["width"] = 200
                o['cellRenderer'] = selectTradeCode
                o['cellRendererParams'] = {
                    color: (params: any, greyCode: any) => {
                        // form.a.planOrderDetails[params.rowIndex].greyCode = greyCode
                        // setTimeout(function () { gridOptionyB.value.setRowData(form.a.planOrderDetails); }, 0)
                    }
                }
            }


            if (o.headerName == '色号') {
                o['resizable'] = true
                o['filter'] = false
                o['sortable'] = false
                o["pinned"] = "light"
                o["width"] = 200
                o['cellRenderer'] = selectColorCode
                o['cellRendererParams'] = {
                    color: (params: any) => {
                        form.a.planOrderDetails[params.rowIndex].colorCode = params.data.colorCode
                        setTimeout(function () { gridOptionyB.value.setRowData(form.a.planOrderDetails); }, 0)
                    }
                }
            }
            if (o.headerName == '色称') {
                o['resizable'] = true
                o['filter'] = false
                o['sortable'] = false
                o["pinned"] = "light"
                o["width"] = 200
                o['cellRenderer'] = selectColorName
                o['cellRendererParams'] = {
                    color: (params: any) => {
                        form.a.planOrderDetails[params.rowIndex].colorName = params.data.colorName
                        setTimeout(function () { gridOptionyB.value.setRowData(form.a.planOrderDetails); }, 0)
                    }
                }
            }

            if (o.headerName == '下单部门') {
                o['resizable'] = true
                o['filter'] = false
                o['sortable'] = false
                o["pinned"] = "light"
                o["width"] = 200
                o['cellRenderer'] = selectOrdering
                o['cellRendererParams'] = {
                    color: (params: any, greyCode: any) => {
                        // form.a.planOrderDetails[params.rowIndex].greyCode = greyCode
                        // setTimeout(function () { gridOptionyB.value.setRowData(form.a.planOrderDetails); }, 0)
                    }
                }
            }
            if (o.headerName == '确认色') {
                o['resizable'] = true
                o['filter'] = false
                o['sortable'] = false
                o["pinned"] = "light"
                o["width"] = 200
                o['cellRenderer'] = selectAffirmColor
                o['cellRendererParams'] = {
                    color: (params: any) => {
                        form.a.planOrderDetails[params.rowIndex].affirmColor = params.data.affirmColor
                        setTimeout(function () { gridOptionyB.value.setRowData(form.a.planOrderDetails); }, 0)
                    }
                }
            }
            // if (o.headerName == '染色类型') {
            //     o['resizable'] = true
            //     o['filter'] = false
            //     o['sortable'] = false
            //     o["pinned"] = "light"
            //     o["width"] = 200
            //     o['cellRenderer'] = selectDyeingType
            //     o['cellRendererParams'] = {
            //         color: (params: any) => {
            //             form.a.planOrderDetails[params.rowIndex].dyeingType = params.data.dyeingType
            //             setTimeout(function () { gridOptionyB.value.setRowData(form.a.planOrderDetails); }, 0)
            //         }greyTyp
            //     }
            // }

            if (o.headerName == '季节') {
                o['resizable'] = true
                o['filter'] = false
                o['sortable'] = false
                o["pinned"] = "light"
                o["width"] = 200
                o['cellRenderer'] = selectSeason
                o['cellRendererParams'] = {
                    color: (params: any) => {
                        form.a.planOrderDetails[params.rowIndex].season = params.data.season
                        setTimeout(function () { gridOptionyB.value.setRowData(form.a.planOrderDetails); }, 0)
                    }
                }
            }
            if (o.headerName == '布种类别') {
                o['resizable'] = true
                o['filter'] = false
                o['sortable'] = false
                o["pinned"] = "light"
                o["width"] = 200
                o['cellRenderer'] = selectGreyType
                o['cellRendererParams'] = {
                    color: (params: any) => {
                        form.a.planOrderDetails[params.rowIndex].greyType = params.data.greyType
                        setTimeout(function () { gridOptionyB.value.setRowData(form.a.planOrderDetails); }, 0)
                    }
                }
            }
            if (o.headerName == '整理收费项目') {
                o['resizable'] = true
                o['filter'] = false
                o['sortable'] = false
                o["pinned"] = "light"
                o["width"] = 200
                o['cellRenderer'] = selectTrimCharges
                o['cellRendererParams'] = {
                    color: (params: any) => {
                        form.a.planOrderDetails[params.rowIndex].trimCharges = params.data.trimCharges
                        setTimeout(function () { gridOptionyB.value.setRowData(form.a.planOrderDetails); }, 0)
                    }
                }
            }
            // if (o.headerName == '颜色深浅') {
            //     o['resizable'] = true
            //     o['filter'] = false
            //     o['sortable'] = false
            //     o["pinned"] = "light"
            //     o["width"] = 200
            //     o['cellRenderer'] = selectColorDepth
            //     o['cellRendererParams'] = {
            //         color: (params: any) => {
            //             form.a.planOrderDetails[params.rowIndex].colorDepth = params.data.colorDepth
            //             setTimeout(function () { gridOptionyB.value.setRowData(form.a.planOrderDetails); }, 0)
            //         }
            //     }
            // }
            if (o.headerName == '珠地边') {
                o['resizable'] = true
                o['filter'] = false
                o['sortable'] = false
                o["pinned"] = "light"
                o["width"] = 150
                o['cellRenderer'] = checheCkEdgeCK
                o['cellRendererParams'] = {
                    color: (params: any,) => {
                        form.a.planOrderDetails[params.rowIndex].edge = params.data.edge
                    }
                }
            }
            if (o.headerName == '撞白') {
                o['resizable'] = true
                o['filter'] = false
                o['sortable'] = false
                o["pinned"] = "light"
                o["width"] = 150
                o['cellRenderer'] = cheCkBumpWhite
                o['cellRendererParams'] = {
                    color: (params: any,) => {
                        form.a.planOrderDetails[params.rowIndex].bumpWhite = params.data.bumpWhite

                    }
                }
            }
            if (o.headerName == '合染类型') {
                o['resizable'] = true
                o['filter'] = false
                o['sortable'] = false
                o["pinned"] = "light"
                o["width"] = 150
                o['cellRenderer'] = cheCKStaining
                o['cellRendererParams'] = {
                    color: (params: any,) => {
                        form.a.planOrderDetails[params.rowIndex].joinDyeType = params.data.joinDyeType

                    }
                }
            }
            if (o.headerName == '一等品') {
                o['resizable'] = true
                o['filter'] = false
                o['sortable'] = false
                o["pinned"] = "light"
                o["width"] = 150
                o['cellRenderer'] = cheCkFirstRate
                o['cellRendererParams'] = {
                    color: (params: any,) => {
                        form.a.planOrderDetails[params.rowIndex].firstRate = params.data.firstRate

                    }
                }
            }
            if (o.headerName == '拔印') {
                o['resizable'] = true
                o['filter'] = false
                o['sortable'] = false
                o["pinned"] = "light"
                o["width"] = 150
                o['cellRenderer'] = CheCkdialPrinting
                o['cellRendererParams'] = {
                    color: (params: any,) => {
                        form.a.planOrderDetails[params.rowIndex].dialPrinting = params.data.dialPrinting
                    }
                }
            }
            if (o.headerName == '温擦提升') {
                o['resizable'] = true
                o['filter'] = false
                o['sortable'] = false
                o["pinned"] = "light"
                o["width"] = 150
                o['cellRenderer'] = cheCkwetRubbing
                o['cellRendererParams'] = {
                    color: (params: any,) => {
                        form.a.planOrderDetails[params.rowIndex].wetRubbing = params.data.wetRubbing

                    }
                }
            }
            if (o.headerName == '白色防粘处理') {
                o['resizable'] = true
                o['filter'] = false
                o['sortable'] = false
                o["pinned"] = "light"
                o["width"] = 150
                o['cellRenderer'] = cheCkstainResistance
                o['cellRendererParams'] = {
                    color: (params: any,) => {
                        form.a.planOrderDetails[params.rowIndex].stainResistance = params.data.stainResistance

                    }
                }
            }
            if (o.headerName == '需进缸') {
                o['resizable'] = true
                o['filter'] = false
                o['sortable'] = false
                o["pinned"] = "light"
                o["width"] = 150
                o['cellRenderer'] = cheCKneedEnterPot
                o['cellRendererParams'] = {
                    color: (params: any,) => {
                        form.a.planOrderDetails[params.rowIndex].needEnterPot = params.data.needEnterPot
                    },
                    data: {
                        needEnterPot: true
                    }
                }
            }
            if (o.headerName == '收取染费') {
                o['resizable'] = true
                o['filter'] = false
                o['sortable'] = false
                o["pinned"] = "light"
                o["width"] = 150
                o['cellRenderer'] = cheCktakeDyeFee
                o['cellRendererParams'] = {
                    color: (params: any,) => {
                        form.a.planOrderDetails[params.rowIndex].takeDyeFee = params.data.takeDyeFee
                    },
                    data: {
                        takeDyeFee: true
                    }
                }
            }
            if (o.headerName == '重打包') {
                o['resizable'] = true
                o['filter'] = false
                o['sortable'] = false
                o["pinned"] = "light"
                o["width"] = 150
                o['cellRenderer'] = cheCkrepeatPack
                o['cellRendererParams'] = {
                    color: (params: any,) => {
                        form.a.planOrderDetails[params.rowIndex].repeatPack = params.data.repeatPack
                    }
                }
            }


            if (o.headerName == '耐氨提升') {
                o['resizable'] = true
                o['filter'] = false
                o['sortable'] = false
                o["pinned"] = "light"
                o["width"] = 150
                o['cellRenderer'] = cheCkChlorineResistant
                o['cellRendererParams'] = {
                    color: (params: any,) => {

                    }
                }
            }


            if (o.headerName == '抗黄处理') {
                o['resizable'] = true
                o['filter'] = false
                o['sortable'] = false
                o["pinned"] = "light"
                o["width"] = 150
                o['cellRenderer'] = cheCkResistanceYellow
                o['cellRendererParams'] = {
                    color: (params: any,) => {

                    }
                }
            }

            // if (o.headerName == '重打包') {
            //     o['resizable'] = false
            //     o['filter'] = false
            //     o['sortable'] = false
            //     o["pinned"] = "light"
            //     o["width"] = 150
            //     o['cellRenderer'] = {
            //         template: `<div>
            //             <a-checkbox @click="s"></a-checkbox>
            //                   </div>`,
            //         setup(props: any) {
            //             const s = () => {
            //                 form.a.planOrderDetails[props.params.rowIndex].repeatPack = form.a.planOrderDetails[props.params.rowIndex].repeatPack == 0 ? 1 : 0
            //             }
            //             return {
            //                 s
            //             }
            //         }

            //     }
            // }

            return o
        })


        const rowData = [
            { make: "Toyota", model: "Celica", price: 35000 },
            { make: "Ford", model: "Mondeo", price: 32000 },
            { make: "Porsche", model: "Boxster", price: 72000 },
            { make: "Toyota", model: "Celica", price: 35000 },
            { make: "Ford", model: "Mondeo", price: 32000 },
            { make: "Porsche", model: "Boxster", price: 72000 },
            { make: "Toyota", model: "Celica", price: 35000 },
            { make: "Ford", model: "Mondeo", price: 32000 },
            { make: "Porsche", model: "Boxster", price: 72000 },
        ];
        /********************************************************************************总坯布信息********************************************************************* */
        const total = [
            {
                headerName: '',//选择列头部显示的文字，可以为空
                checkboxSelection: true,//设置为ture显示为复选框
                headerCheckboxSelection: true, //表头是否也显示复选框，全选反选用
                pinned: 'left', //固定再左边
                width: 50 //列的宽度
            },
            { headerName: "布号", field: "greyCode", },
            { headerName: "品名", field: "greyName" },
            { headerName: "色号", field: "yarnHouseNum" },
            { headerName: "色称", field: "houseNum", },
            { headerName: "备坯单号", field: "weight" },
            { headerName: "坯布名称", field: "lenghtNum" },
            { headerName: "等级", field: "clothCode", },
            { headerName: "机台号", field: "productName" },
            { headerName: "纱批", field: "colorCode" },
            { headerName: "匹数", field: "colorName", },
            { headerName: "重量", field: "larghezza" },
            { headerName: "织厂", field: "larghezza" },
        ];

        //测试标准
        function testCriterionFun() {
            post({
                url: "/pdm/VerifyStandard/getFieldValue",
                data: {
                    verifyStandard: ''
                }
            }).then(({ data, code }: any) => {
                if (code === 200) {
                    basicData.VerifyStandard = data
                }

            }).catch(console.log).finally(() => {
                pageData.pageLoading = false
            });
        }

        function testCriterionCk(val: any) {
            post({
                url: "/pdm/CustomVerifyProject/getAllInfo",
                data: {
                    verifyStandard: val
                }
            }).then(({ data, code }: any) => {
                if (code === 200) {
                    testAskList.list = data
                    shrink.w = data[0].verifyMinNum
                    shrink.l = data[0].verifyMinNum


                }

            }).catch(console.log).finally(() => {
                pageData.pageLoading = false
            });
        }


        /*****************************************************对色光源****************************************************** */
        //下拉框焦点
        const coloringIlluminantFun = () => {
            coloringIlluminantAll({ colourLight: '' })
        };
        //下拉数据
        let pageDataList = ref([])
        let options = ref<any>(pageDataList.value);
        let loading = ref(false);
        const coloringIlluminantSear = (val: any) => {
            loading.value = true;
            coloringIlluminantAll({ colourLight: val });
            options.value = pageDataList.value;
            loading.value = false;
        };
        function coloringIlluminantAll(val: any) {
            post({
                url: "/pdm/coloringMatch/getFieldValue",
                data: val
            }).then(({ data, code }: any) => {
                if (code === 200) {
                    pageDataList.value = data;
                } else {
                    Message.error({
                        content: "查询失败！",
                        duration: 5000,
                    });
                }
            });
        }
        /****************************************************************客户名称************************************************************** */
        const customNameFun = () => {
            customNameAll({ customName: '' })
        };
        const customNameSear = (val: any) => {
            loading.value = true;
            coloringIlluminantAll({ customName: val });
            options.value = pageDataList.value;
            loading.value = false;
        };
        function customNameAll(val: any) {
            post({
                url: "/aps/custom/getDropValue",
                data: val
            }).then(({ data, code }: any) => {
                if (code === 200) {
                    pageDataList.value = data;
                } else {
                    Message.error({
                        content: "查询失败！",
                        duration: 5000,
                    });
                }
            });
        }







        /********************************************************订单性质****************************************************/
        function orderNatureFun(backName: any) {
            post({
                url: "dict/dictType/getList",
                data: {
                    typeName: backName,
                    deleteState: 0
                }
            }).then(({ data, code }: any) => {
                if (code === 200) {
                    if (data[0].codeType != 'undefined') {
                        getOrderNature(data[0].codeType, backName)
                    }
                }
            }).catch(console.log).finally(() => {
                pageData.pageLoading = false
            });
        }

        function getOrderNature(codeType: any, dictionary: any) {
            post({
                url: "dict/dictTypeDetail/getList",
                data: {
                    codeType: codeType,
                    obsoleteState: 0,
                    deleteState: 0
                }
            }).then(({ data, code }: any) => {
                if (code === 200) {
                    switch (dictionary) {
                        case '订单性质':
                            basicData.orderNature = data
                            break;
                        case '结算方式':
                            basicData.Calculation = data
                            break;
                        case '面料销售类型':
                            basicData.plusMaterial = data
                            break;
                        case '结算公司':
                            basicData.corporation = data
                            break;
                    }
                }
            }).catch(console.log).finally(() => {
                pageData.pageLoading = false
            });
        }

        /***********************************************标签格式****************************************************/
        const labelFormatCodeFun = () => {
            labelFormatCodeAll({ labelFormat: '' })
        };
        const labelFormatCodeSear = (val: any) => {
            loading.value = true;
            labelFormatCodeAll({ labelFormat: val });
            options.value = pageDataList.value;
            loading.value = false;
        };
        function labelFormatCodeAll(val: any) {
            post({
                url: "/aps/labelFormat/getDropValue",
                data: val
            }).then(({ data, code }: any) => {
                if (code === 200) {
                    pageDataList.value = data;
                } else {
                    Message.error({
                        content: "查询失败！",
                        duration: 5000,
                    });
                }
            });
        };
        /***********************************************标签格式****************************************************/
        const exchangeCalorieClassifyFun = () => {
            exchangeCalorieClassifyAll({ exchangeCalorieClassify: '' })
        };
        const exchangeCalorieClassifySear = (val: any) => {
            loading.value = true;
            exchangeCalorieClassifyAll({ exchangeCalorieClassify: val });
            options.value = pageDataList.value;
            loading.value = false;
        };
        function exchangeCalorieClassifyAll(val: any) {
            post({
                url: "/aps/ExchangecalorieClassify/getDropValue",
                data: val
            }).then(({ data, code }: any) => {
                if (code === 200) {
                    pageDataList.value = data;
                } else {
                    Message.error({
                        content: "查询失败！",
                        duration: 5000,
                    });
                }
            });
        };
        /***************************************************回修原因********************************************************** */
        const repairCauseFun = () => {
            repairCauseAll({ repairCause: '' })
        };
        const repairCauseSear = (val: any) => {
            loading.value = true;
            repairCauseAll({ repairCause: val });
            options.value = pageDataList.value;
            loading.value = false;
        };
        function repairCauseAll(val: any) {
            post({
                url: "/dwWorkShop/repairCause/selectRepairCause",
                data: val
            }).then(({ data, code }: any) => {
                if (code === 200) {
                    pageDataList.value = data.data;
                } else {
                    Message.error({
                        content: "查询失败！",
                        duration: 5000,
                    });
                }
            });
        };
        /************************************************总部坯布查询********************************************* */
        function countBu() {
            post({
                url: "/wms/GreyStock/getClothInfo",
                data: {
                    greyCode: '1',
                    greyName: '1'
                }
            }).then(({ data, code }: any) => {
                if (code === 200) {
                    planOderGreys.value = data;
                } else {
                    Message.error({
                        content: "查询失败！",
                        duration: 5000,
                    });
                }
            });
        };

        /*****************************************************导入后台巨客户******************************************************** */
        let yesOrderList: any = [];
        const gridOptionB = ref()
        const gridReadyB = (params: any) => {
            gridOptionB.value = params.api
        }

        const gridOptionC = ref()
        const gridReadyC = (params: any) => {
            gridOptionC.value = params.api
        }


        let planOrderDetails = {
            serialNo: 0,
            productionMode: '',
            machinType: '外加工染色',
            dyeingType: '',
            cylinderType: '',
            workshop: '',
            clothCode: '',
            productName: '',
            colorCode: '',
            colorName: '',
            affirmColor: '',
            colorDepth: '',
            contrastColor: '',
            houseNum: '',
            finishedWeight: '',
            castDyeWeight: '',
            allLoss: '',
            trimCharges: '',
            joinDyeType: '',
            firstRate: '',
            bumpWhite: '',
            wetRubbing: '',
            chlorineResistant: '',
            stainResistance: '',
            resistanceYellow: '',
            dialPrinting: '',
            repeatPack: '',
            needEnterPot: '',
            takeDyeFee: '',
            season: '',
            greyType: '',
            greyCode: '',
            greyName: '',
            ingredient: '',
            yarnCount: '',
            edge: '',
            efficacious: '',
            gramWeight: '',
            upperLimit: '',
            lowerLimit: '',
            gramUpperLimit: '',
            gramLowerLimit: '',
            tradeCode: '',
            tradeName: '',
            finishedClothCode: '',
            finishedClothName: '',
            tradeEfficacious: '',
            tradeGramWeight: '',
            hqCardNumber: '',
            rawColorCode: '',
            rawColorName: '',
            customClothCode: '',
            customProductName: '',
            customColorCode: '',
            customColorName: '',
            customPo: '',
            styleNumber: '',
            finalize: '',
            quality: '',
            orderDepartment: '',
            repairMachineCode: '',
            repairClothCode: '',
            repairColorCode: '',
            repairColorName: '',
            prodId: '',
            seqNo: '',
            shiptoSite: '',
            letmap: 0,

        };

        //订单明细新增
        const planOrderDetailsAdd = () => {
            planOrderDetails.serialNo = planOrderDetails.serialNo + 1
            form.a.planOrderDetails.push(JSON.parse(JSON.stringify(planOrderDetails)))
            setTimeout(function () { gridOptionyB.value.setRowData(form.a.planOrderDetails); }, 0)
        }
        const gridOptionyB = ref();
        const gridReadyeB = (params: any,) => {
            gridOptionyB.value = params.api
            console.log("触发");
        };
        const orderCustomList = reactive({
            list: []
        });
        const exCustomer = () => {
            for (let key in guanxiForm) {
                guanxiForm[key] = ''
            }
            guanxiForm.auditState = 0
            guanxiCount()
            pageData.showAdd = false
            pageData.importAdd = true
        };
        const trigger = ref('1');
        const showJu = ref<boolean>(true)
        const hugeCustomer = [
            {
                headerName: '',//选择列头部显示的文字，可以为空
                checkboxSelection: true,//设置为ture显示为复选框
                headerCheckboxSelection: true, //表头是否也显示复选框，全选反选用
                pinned: 'left', //固定再左边
                width: 50 //列的宽度
            },
            { headerName: "客户订单号", field: "customOrderCode", },
            { headerName: "卖家名称", field: "buyerName" },
            { headerName: "客户名称", field: "customOrderName" },
            { headerName: "客户跟单", field: "clientDocumentary", },
            { headerName: "下单日期", field: "authorizedStrengthTime" },
            { headerName: "交货日期", field: "deliveryTime" },
            { headerName: "季节", field: "season", },
            { headerName: "款号", field: "styleNumber" },
            { headerName: "布号", field: "clothCode" },
            { headerName: "品名", field: "productName", },
            { headerName: "系统品名", field: "systemProductName", },
            { headerName: "门幅", field: "larghezza" },
            { headerName: "克重", field: "gWeight" },
            { headerName: "颜色代码", field: "colorNum" },
            { headerName: "色号", field: "colorCode" },
            { headerName: "色称", field: "colorName" },
            { headerName: "确认色", field: "affirmColor" },
            { headerName: "客户色称", field: "customColorName" },
            { headerName: "对色资料", field: "contrastColor" },
            { headerName: "测试标准", field: "testCriterion" },
            { headerName: "成分", field: "ingredient" },
            { headerName: "po号", field: "customPoCode" },
            { headerName: "投染重量", field: "castDyeWeight" },
            { headerName: "投染码数", field: "castDyeYardage" },
            { headerName: "投染磅数", field: "castDyePound" },

            { headerName: "成品磅数", field: "finishedClothPound" },
            { headerName: "备注", field: "remark" },
            { headerName: "导入人", field: "importPerson" },
            { headerName: "导入日期", field: "importDate" },
            { headerName: "客户品名", field: "customProductName" },
        ];

        function checkDuplicateClothCode(array: any) {
            // var clothCodeSet = new Set();
            // for (var i = 0; i < array.length; i++) {
            //     var item = array[i];
            //     if (clothCodeSet.has(item.customOrderCode)) {
            //         return true;
            //     }
            //     clothCodeSet.add(item.customOrderCode);
            // }
            // return false;
            const firstId = array[0].customOrderCode;
            for (let i = 1; i < array.length; i++) {
                if (array[i].customOrderCode != firstId) {
                    return false;
                }
            }
            return true;
        }
        // 数据流方法
        const sideaOKcopy = () => {
            yesOrder()
            if (yesOrderList.length > 0) {
                form.a.placeDepartment = yesOrderList[0].firmName
                form.a.deliveryAddress = yesOrderList[0].deliveryAddress
                form.a.hqCraft = yesOrderList[0].hqCraft
                form.a.customOrderCode = yesOrderList[0].customOrderCode
                form.a.testCriterion = yesOrderList[0].testCriterion
                form.a.customOrderName = yesOrderList[0].customOrderName
                form.a.authorizedStrengthTime = new Date(yesOrderList[0].authorizedStrengthTime)
                form.a.customName = '台巨纺织'
                form.a.ultimatelyBuyer = yesOrderList[0].buyerName
                form.a.require = yesOrderList[0].remark
                form.a.lastDeliveryTime = new Date(yesOrderList[0].deliveryTime)
                for (let i = 0; i < yesOrderList.length; i++) {
                    let a = { ...planOrderDetails, ...yesOrderList[i] }
                    a.machinType = '外加工染色'
                    if (a.customName == '台巨') {
                        console.log(a.colorCode)
                        // if(a.colorCode){
                        //     a.affirmColor = a.colorCode.split('-')[2].match(/[A-Za-z]/)[0]
                        // }
                    }
                    a.customProductName = a.customProductName
                    a.customColorCode = a.colorNum
                    a.customPo = a.customPoCode
                    a.shiptoSite = a.shipto
                    a.affirmColor = a.colorCode.split('-')[a.colorCode.split('-').length - 1]
                    a.finishedWeight = Number(a.weightB)
                    if (a.castDyeWeight === 0) {
                        a.allLoss = 0
                    } else {
                        a.allLoss = Number(a.weightB) / a.castDyeWeight
                    }
                    a.finishedWeight = a.finishedClothPound
                    a.allLoss = Number(a.finishedClothPound / a.castDyeWeight).toFixed(2)
                    post({
                        url: "pdm/DevFabricInfo/getInfoByCloth",
                        data: {
                            "clothCode": a.clothCode,
                            "colorCode": a.colorCode
                        }
                    }).then(({ data, code }) => {
                        if (code === 200) {
                            a.cylinderType = data[0]?.cylinderType
                            // a.colorDepth = data[0]?.colorDepth
                            // a.dyeingType = data[0]?.dyeTypeName
                            a.craftCode = data[0]?.produceFlowName
                            a.greyType = data[0]?.clothKindType
                            a.efficacious = data[0]?.validWidth
                            a.upperLimit = data[0]?.widthUpperLimit
                            a.lowerLimit = data[0]?.widthLowerLimit
                            a.gramWeight = data[0]?.fabricWeight
                            a.gramUpperLimit = data[0]?.weightUpperLimit
                            a.gramLowerLimit = data[0]?.weightLowerLimit
                            a.greyCode = data[0]?.grayCode
                        } else {
                            Message.error({
                                content: "查询失败！",
                                duration: 5000,
                            });
                        }
                    });
                    form.a.planOrderDetails.push(JSON.parse(JSON.stringify(a)))
                    setTimeout(function () { gridOptionyB.value.setRowData(form.a.planOrderDetails); }, 0)
                }
                form.a.colourSum = form.a.planOrderDetails.length
                if (form.a.orderCode == '') {
                    for (let i = 0; i < form.a.planOrderDetails.length; i++) {
                        if (form.a.planOrderDetails[i].machinType != '') {
                            machinTypeFun(form.a.planOrderDetails[i].machinType)
                            break;
                        }
                    }
                }
                showJu.value = false
            }
            pageData.importAdd = false
            pageData.showAdd = true;
            count()
        }
        //导入巨客户订单
        const sideaOk = () => {
            if (mobanYnKey.value == 1) {
                if (gridOptionB.value.getSelectedRows().length === 0) {
                    pageData.importAdd = false
                } else if (gridOptionB.value.getSelectedRows().length === 1) {
                    sideaOKcopy()
                } else {
                    if (!checkDuplicateClothCode(gridOptionB.value.getSelectedRows())) {
                        // Message.error({
                        //     content: "选取的数据 客户订单号 必须相同！",
                        //     duration: 5000,
                        // });
                        // 这里的判断为所勾选的数据中客订号不同
                        let obList = gridOptionB.value.getSelectedRows()
                        // const idList = obList.map((item: any) => item.id);
                        const idList: any = [];
                        obList.forEach((item: any) => {
                            if ('id' in item) {
                                idList.push({ id: item['id'] });
                            }
                        });
                        let newBool = false
                        post({
                            url: "aps/planOrder/addInfo",
                            data: idList
                        }).then(({ data, code }) => {
                            if (code === 200) {
                                emitter.emit('inCompanyName', newBool);
                                yesOrder()
                                showJu.value = false
                                pageData.importAdd = false
                                pageData.showAdd = true;
                            }
                        });
                    } else {
                        yesOrder()
                        if (yesOrderList.length > 0) {
                            form.a.placeDepartment = yesOrderList[0].firmName
                            form.a.deliveryAddress = yesOrderList[0].deliveryAddress
                            form.a.hqCraft = yesOrderList[0].hqCraft
                            form.a.customOrderCode = yesOrderList[0].customOrderCode
                            form.a.testCriterion = yesOrderList[0].testCriterion
                            form.a.customOrderName = yesOrderList[0].customOrderName
                            form.a.authorizedStrengthTime = new Date(yesOrderList[0].authorizedStrengthTime)
                            form.a.customName = '台巨纺织'
                            form.a.ultimatelyBuyer = yesOrderList[0].buyerName
                            form.a.require = yesOrderList[0].remark
                            form.a.lastDeliveryTime = new Date(yesOrderList[0].deliveryTime)
                            for (let i = 0; i < yesOrderList.length; i++) {
                                let a = { ...planOrderDetails, ...yesOrderList[i] }
                                a.machinType = '外加工染色'
                                a.customProductName = a.customProductName
                                a.customColorCode = a.colorNum
                                a.customPo = a.customPoCode
                                a.shiptoSite = a.shipto
                                a.finishedWeight = Number(a.weightB)
                                a.affirmColor = a.colorCode.split('-')[a.colorCode.split('-').length - 1]
                                if (a.castDyeWeight === 0) {
                                    a.allLoss = 0
                                } else {
                                    a.allLoss = Number(a.weightB) / a.castDyeWeight
                                }
                                a.allLoss = Number(a.finishedClothPound / a.castDyeWeight).toFixed(2)

                                post({
                                    url: "pdm/DevFabricInfo/getInfoByCloth",
                                    data: {
                                        "clothCode": a.clothCode,
                                        "colorCode": a.colorCode
                                    }
                                }).then(({ data, code }) => {
                                    if (code === 200) {
                                        // dataList.value = data[0].
                                        a.cylinderType = data[0]?.cylinderType
                                        a.colorDepth = data[0]?.colorDepth
                                        a.dyeingType = data[0]?.dyeTypeName
                                        a.craftCode = data[0]?.produceFlowName
                                        a.greyType = data[0]?.clothKindType
                                        a.efficacious = data[0]?.validWidth
                                        a.upperLimit = data[0]?.widthUpperLimit
                                        a.lowerLimit = data[0]?.widthLowerLimit
                                        a.gramWeight = data[0]?.fabricWeight
                                        a.gramUpperLimit = data[0]?.weightUpperLimit
                                        a.gramLowerLimit = data[0]?.weightLowerLimit

                                    } else {
                                        Message.error({
                                            content: "查询失败！",
                                            duration: 5000,
                                        });
                                    }
                                });
                                form.a.planOrderDetails.push(JSON.parse(JSON.stringify(a)))
                                setTimeout(function () { gridOptionyB.value.setRowData(form.a.planOrderDetails); }, 0)
                            }
                            form.a.colourSum = form.a.planOrderDetails.length
                            if (form.a.orderCode == '') {
                                for (let i = 0; i < form.a.planOrderDetails.length; i++) {
                                    if (form.a.planOrderDetails[i].machinType != '') {
                                        machinTypeFun(form.a.planOrderDetails[i].machinType)
                                        break;
                                    }
                                }
                            }
                            showJu.value = false
                        }
                        pageData.importAdd = false
                        pageData.showAdd = true;
                        count()
                    }
                }
            } else if (mobanYnKey.value == 2) {
                post({
                    url: "aps/orderCustom/delete",
                    data: gridOptionC.value.getSelectedRows().map((res: any) => {
                        return res.id
                    })
                }).then(({ data, code }) => {
                    if (code === 200) {
                        guanxiForm.auditState = 1
                        guanxiCount()
                    }
                });
            }


        };
        const yesOrder = () => {
            yesOrderList = gridOptionB.value.getSelectedRows()
            if (trigger.value == '1') {
                gridOptionB.value.getSelectedRows().map((item) => {
                    // 循环勾选数据
                    // return item.customOrderCode
                    return orderCustomList.list.map((se, index) => {
                        // 循环表格总数据
                        if (se.id === item.id) {
                            orderCustomList.list.splice(index, 1)
                            setTimeout(function () { gridOptionB.value.setRowData(orderCustomList.list); }, 0)
                        }
                    })
                })
            } else {
                gridOptionB.value.getSelectedRows().map((item) => {
                    return item.customOrderCode
                })
            }

            console.log(yesOrderList, 'ss')
            baocun(yesOrderList)

        }
        const baocun = (data: any) => {
            post({
                url: "/aps/orderCustom/confirm",
                data: data
            }).then(({ data, code, message }: any) => {
                // console.log(data,"下拉返回");
                if (code === 200) {
                    Message.success({
                        content: "保存成功",
                        duration: 200,
                    });

                } else {
                    Message.error({
                        content: message,
                        duration: 5000,
                    });
                }
            });
        }
        let guanxiData = {
            houseNum: 0,
            finishedWeight: 0,
            castDyeWeight: 0
        }
        function count() {
            let a = 0;
            let b = 0;
            let c = 0;
            for (var i = 0; i < form.a.planOrderDetails.length; i++) {
                a = a + Number(form.a.planOrderDetails[i].houseNum)
                b = b + Number(form.a.planOrderDetails[i].finishedWeight)
                c = c + Number(form.a.planOrderDetails[i].castDyeWeight)
            }
            var topRows = [
                { headerName: '合计', houseNum: a, finishedWeight: b, castDyeWeight: c }
            ];
            guanxiData = {
                houseNum: Number(a),
                finishedWeight: Number(b),
                castDyeWeight: Number(c)
            }
            // gridOptionyB.value.setPinnedBottomRowData(topRows);
        };

        const sideaNo = () => {
            // for (let i = 0; i < yesOrderList.length; i++) {
            //     let a = { ...planOrderDetails, ...yesOrderList[i] }
            //     form.a.planOrderDetails.push(JSON.parse(JSON.stringify(a)))
            //     setTimeout(function () { gridOptionyB.value.setRowData(form.a.planOrderDetails); }, 0)
            // }

            pageData.importAdd = false
            pageData.showAdd = true;

            // 传递新增页面的指示！
            // console.log(Tchoocl.showAdd, '试试不传递能否有效')
            count()
        };

        //查询
        const guanxiCount = () => {
            post({
                url: "/aps/orderCustom/getList",
                data: guanxiForm
            }).then(({ data, code }: any) => {
                // console.log(data,"下拉返回");
                console.log(data)
                if (code === 200) {
                    orderCustomList.list = data;
                }
            });
        };

        const mobanYnKey: any = ref(1)


        const mobanYn = (key: any) => {
            mobanYnKey.value = key
            if (key == 1) {
                guanxiForm.auditState = 0
                guanxiCount()
            } else {
                guanxiForm.auditState = 1
                guanxiCount()
            }
        }
        //模板下载
        const downloadHandler = () => {
            axios.get('/api/aps/orderCustom/uploadOrderCustomeModel', {
                responseType: 'blob',
                headers: {
                    token: sessionStorage.getItem('USER-TOKEN-KEY')
                }
            }).then((res) => {
                if (res.status === 200) {
                    filedownload(res.data, '巨客户模板.xlsx')
                }
            })
        };

        //导入
        const importHandler = () => {
            const inputEle: HTMLInputElement = document.createElement('input')
            inputEle.type = 'file'
            inputEle.id = 'fileUploadExcel'
            inputEle.accept = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel'
            inputEle.addEventListener('change', (e) => {
                const formData = new FormData()
                if (inputEle.files !== null) {
                    formData.append('file', inputEle.files[0] || '')
                    formData.append('customOrderCode', form.a.customOrderCode)
                } else {
                    Message.warning('未选择文件！');
                    return
                }
                pageData.pageLoading = true
                axios.post('/api/aps/orderCustom/analyseOrderCustomeModel',
                    formData,
                    {
                        headers: {
                            "Content-Type": 'multipart/form-data',
                            "token": sessionStorage.getItem('USER-TOKEN-KEY')
                        },
                    }).then((result) => {
                        if (result.data['code'] === 200) {
                            for (let i = 0; i < result.data['data'].length; i++) {
                                result.data['data'][i].id = null
                            }
                            orderCustomList.list = result.data['data']
                            Message.success('导入成功')
                            guanxiCount()
                        } else {
                            Message.error(result.data.message)
                        }

                    }).finally(() => {
                        // pageData.pageLoading = false
                        // doRefresh()
                        post({
                            url: "/aps/orderCustom/getList",
                        }).then(({ data, code }: any) => {
                            if (code === 200) {
                                // orderCustomList.list = data
                            }
                        }).catch(console.log).finally(() => {
                            pageData.pageLoading = false
                        });
                    })
            })
            inputEle.click()
        }

        /*******************************************取布号********************************************************/
        const clothCodeBoSel = () => {
            clothCodeAll({ clothCode: "", auditState: 1, deleteState: 0, obsoleteState: 0 })
        }
        let optionsList = ref([])
        let clothCodeList = ref<any>(optionsList.value);
        let clothCodeBo = ref(false);

        const clothCodeSearch = (value: any) => {
            const ob = { clothCode: value, auditState: 1, deleteState: 0, obsoleteState: 0 }
            clothCodeBo.value = true;
            clothCodeAll(ob);
            clothCodeList.value = optionsList.value;
            clothCodeBo.value = false;
        };

        function clothCodeAll(val: any) {
            post({
                url: "/pdm/DevFabricInfo/getLikeList",
                data: val
            }).then(({ data, code, message }: any) => {
                if (code === 200) {
                    optionsList.value = data;
                } else {
                    Message.error({
                        content: message,
                        duration: 5000,
                    });
                }
            });
        }

        /********************************************************************取品名************************************************************************ */
        let pinList = ref([])
        const clothCodeBoSelA = () => {
            clothCodeAllA({ brandName: "", auditState: 1, deleteState: 0, obsoleteState: 0 })
        }
        let clothCodeListA = ref<any>(pinList.value);
        let clothCodeBoA = ref(false);

        const clothCodeSearchA = (value: any) => {
            const ob = { brandName: value, auditState: 1, deleteState: 0, obsoleteState: 0 }
            clothCodeBoA.value = true;
            clothCodeAllA(ob);
            clothCodeListA.value = pinList.value;
            clothCodeBoA.value = false;
        };

        function clothCodeAllA(val: any) {
            post({
                url: "/pdm/DevFabricInfo/getLikeList",
                data: val
            }).then(({ data, code, message }: any) => {
                if (code === 200) {
                    pinList.value = data;
                } else {
                    Message.error({
                        content: message,
                        duration: 5000,
                    });
                }
            });
        }
        const getSonList = ref([])
        function GetSon() {
            post({
                url: "/pdm/RequireClassify/getSon",
            }).then((re: any) => {
                if (re.length > 0) {
                    form.a.requirement = re
                } else {
                    Message.error({
                        content: '客户要求查询出错',
                        duration: 5000,
                    });
                }

            });
        }
        function testGetSon() {
            post({
                url: "/pdm/CustomVerifyProject/getAllInfo",
                data: { verifyStandard: '测试14' }
            }).then(({ data, code, message }: any) => {
                if (code === 200) {
                    form.a.planOrderTest = data;
                } else {
                    Message.error({
                        content: message,
                        duration: 5000,
                    });
                }
            });
        }
        function orderCodeFun() {
            post({
                url: "/pdm/CustomVerifyProject/getAllInfo",
                data: { verifyStandard: '测试14' }
            }).then(({ data, code, message }: any) => {
                if (code === 200) {
                    form.a.planOrderTest = data;
                } else {
                    Message.error({
                        content: message,
                        duration: 5000,
                    });
                }
            });
        }

        /************************************************************************************下单部门*********************************************************************************** */
        const placeDepartmentFun = () => {
            placeDepartmentAll({ name: '' })
        };
        const placeDepartmentSear = (val: any) => {
            loading.value = true;
            placeDepartmentAll({ name: val });
            options.value = pageDataList.value;
            loading.value = false;
        };
        function placeDepartmentAll(val: any) {
            post({
                url: "/org/hrDepartment/getLikeList",
                data: val
            }).then(({ data, code }: any) => {
                if (code === 200) {
                    pageDataList.value = data;

                } else {
                    Message.error({
                        content: "查询失败！",
                        duration: 5000,
                    });
                }
            });
        };


        function save() {
            form.a.pack = basicData.pack + '/' + basicData.packA + '/' + basicData.packB

            post({
                url: "/aps/planOrder/insert",
                data: form.a
            }).then(({ data, code, message }: any) => {
                if (code === 200) {
                    Message.success({
                        content: message,
                        duration: 200,
                    });
                } else {
                    Message.error({
                        content: message,
                        duration: 5000,
                    });
                }
            });
        };
        function toExamine(auditState: any) {
            let arr = []
            for (let i = 0; i < form.a.planOrderDetails.length; i++) {
                arr.push({ detail1Id: 0, auditState: auditState, orderCode: form.a.orderCode, serialNo: form.a.planOrderDetails[i].serialNo })
            }
            post({
                url: "/aps/planOrder/audit",
                data: arr
            }).then(({ data, code }: any) => {
                if (code === 200) {
                    Message.success({
                        content: "保存成功",
                        duration: 200,
                    });
                } else {
                    Message.error({
                        content: "查询失败！",
                        duration: 5000,
                    });
                }
            });
        }

        //获取订单号
        function machinTypeFun(val: any) {
            post({
                url: "/aps/planOrder/getAutomaticInfo",
                data: {
                    machinType: val
                }
            }).then(({ data, code }: any) => {
                if (code === 200) {
                    form.a.orderCode = data.maxOrderCode
                }
            }).catch(console.log).finally(() => {
                pageData.pageLoading = false
            });
        };
        onMounted(() => {
            GetSon();
            testGetSon();

        })

        const clothChanges = (val: any) => {
            const evenNumbers = optionsList.value.filter((res) => res.clothCode == val);
            guanxiForm.productName = evenNumbers[0].brandName
        }
        const clothChangess = (val: any) => {
            const evenNumbers = optionsList.value.filter((res) => res.brandName == val);
            guanxiForm.clothCode = evenNumbers[0].clothCode
        }
        const localeText1: any = ref(localeText)

        return {
            sideaOKcopy,
            clothChanges,
            clothChangess,
            localeText1,
            headerShow,
            exCustomer,
            form,
            basicData,
            guanxiForm,
            testAsk,
            testAskList,
            defaultColDef,
            columnsOrder,
            tco,
            defaultColDefTc,
            total,
            testCriterionFun,
            pageData,
            coloringIlluminantFun,
            pageDataList,
            options,
            loading,
            coloringIlluminantSear,
            coloringIlluminantAll,
            customNameFun,
            customNameSear,
            customNameAll,
            orderNatureFun,
            getOrderNature,
            labelFormatCodeFun,
            labelFormatCodeSear,
            labelFormatCodeAll,
            repairCauseFun,
            repairCauseSear,
            repairCauseAll,
            countBu,
            sideaOk,
            yesOrder,
            yesOrderList,
            planOrderDetails,
            gridOptionyB,
            gridReadyeB,
            count,
            gridOptionB,
            gridReadyB,
            orderCustomList,
            baocun,
            guanxiData,
            sideaNo,
            Search,
            CirclePlus,
            guanxiCount,
            downloadHandler,
            importHandler,
            clothCodeBoSel,
            optionsList,
            clothCodeList,
            clothCodeBo,
            clothCodeSearch,
            clothCodeAll,
            pinList,
            clothCodeBoSelA,
            clothCodeListA,
            clothCodeBoA,
            clothCodeSearchA,
            clothCodeAllA,
            mobanYn,
            hugeCustomer,
            gridOptionC,
            gridReadyC,
            defaultColDefBc,
            rowData,
            planOrderDetailsAdd,
            askList,
            GetSon,
            getSonList,
            planOderGreys,
            testGetSon,
            exchangeCalorieClassifyFun,
            exchangeCalorieClassifySear,
            exchangeCalorieClassifyAll,
            save,
            orderCodeFun,
            machinTypeFun,
            toExamine,
            xuHaoFun,
            placeDepartmentFun,
            placeDepartmentSear,
            placeDepartmentAll,
            testCriterionCk,
            shrink,
            cheCkChlorineResistant,
            cheCkResistanceYellow,
            checkDuplicateClothCode,
            mobanYnKey
        }
    },
    components: {
        Toolbar,
        tagRender,
        cheCk,
        cheCkBumpWhite,
        CheCkdialPrinting,
        checheCkEdgeCK,
        cheCkFirstRate,
        cheCKneedEnterPot,
        cheCkrcInfo,
        cheCkrepeatPack,
        cheCkstainResistance,
        cheCktakeDyeFee,
        cheCkwetRubbing,
        selectGreyCode,
        selectGreyName,
        selectColorCode,
        selectColorName,
        selectAffirmColor,
        selectGreyType,
        selectTrimCharges,
        selectDyeingType,
        selectColorDepth,
        selectProductionMode,
        selectMachinType,
        selectWorkshop,
        cheCKStaining,
        selectOrdering,
        selectFabricNumberZ,
        selectColorCodeZ,
        selectColorNameZ,
        selectCylinder
    }

};
</script>
<style  lang="less">
.my-header {
    background-color: #fff;
}

.pagings {
    margin-top: 10px;
    display: flex;
    justify-content: center;
}

.arco-input-wrapper {
    background-color: #fff !important;
    border: 1px solid #cccccc;
}

.arco-form-item-status-error .arco-input-wrapper:not(.arco-input-disabled),
.arco-form-item-status-error .arco-textarea-wrapper:not(.arco-textarea-disabled) {
    border: 1px solid #f53f3f;
}


/********************************************** */
.stbutencx {
    background-color: #409eff;

    &:hover {
        background-color: #79bbff;
    }
}


.ag-header-cell-resize::after {
    top: 0 !important;
    height: 100% !important;
}

.ag-cell {
    border-right: 1px solid #D9DDDF !important;
}

.stbutenxz {
    background-color: #67c23a;

    &:hover {
        background-color: #b3e19d;
    }
}

.el-row {
    margin-bottom: 20px;
}

.el-row:last-child {
    margin-bottom: 0;
}

.el-col {
    border-radius: 4px;
}

.grid-content {
    border-radius: 4px;
    min-height: 36px;
}

/************************************************** */
</style>